Skip to content

Keeping query strings out of the HTTP request log - #94

Open
erkin-io wants to merge 1 commit into
OpenIPC:masterfrom
erkin-io:fix/http-query-log
Open

erkin-io wants to merge 1 commit into
OpenIPC:masterfrom
erkin-io:fix/http-query-log

Conversation

@erkin-io

Copy link
Copy Markdown
Contributor

What was wrong

Every HTTP request is logged with its full URI. API calls that change settings carry secrets in the query string, for example /api/onvif?auth_pass=... and /api/rtsp?auth_pass=..., so passwords end up in the console output and in any log file or log collector that captures it.

Why

parse_request() (src/server.c) prints New request: (GET) <uri> and only afterwards splits the query off the URI (strchr(req->uri, '?')), so the log line contains everything.

What this changes

The query is split off first and the log line shows the path followed by ?... when a query was present (/api/onvif?...). Nothing else in request handling changes: req->uri and req->query hold the same values as before when the handlers run.

How it was checked

  • Built with ./build.sh fhan-v2, no new warnings.
  • By reading the code: the split moved up by a few lines; the check for .. in the URI that follows it, and everything after, sees the same strings.

Effect on other platforms

Shared web server code, compiled for all targets; only the text of one log line changes. No new headers or calls. The cost is some debugging convenience: the parameters of a call no longer appear in the log. If the maintainers want them for debugging, a build flag or DEBUG_HTTP is a possible home.

🤖 Generated with Claude Code

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

PR Summary by Qodo

Keep query strings out of HTTP request logs

🐞 Bug fix 🕐 Less than 10 minutes

Grey Divider

AI Description

• Prevent passwords and other query parameters from appearing in HTTP request logs.
• Preserve the existing path and query values for request validation and handlers.
Diagram

graph TD
  R["HTTP request"] --> P["Split URI"] --> L["Redacted log"] --> V["Path validation"] --> H["Request handlers"]
Loading
High-Level Assessment

Splitting the URI before logging reuses parsing the server already performs and keeps query contents out of this log line without changing handler inputs. A separate log-specific sanitizer would add complexity without a clear benefit for this localized fix.

Files changed (1) +6 / -4

Bug fix (1) +6 / -4
server.cRedact query contents from request log lines +6/-4

Redact query contents from request log lines

• Moves the existing URI/query split ahead of the request log statement. The log now prints the path with '?...' when a query is present, while retaining the separated path and query for subsequent processing.

src/server.c

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)

Grey Divider

Great, no issues found!

Qodo reviewed your code and found no material issues that require review

Grey Divider

Tip of the day
💡 Did you know, you can choose which labels appear on a finding, and whether they show icons or text

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant